package com.nlp.visualization.core.discourse;

import com.nlp.visualization.common.CONSTANTS;
import com.nlp.visualization.pojo.NLP.discourse.WordCloudBackground;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.util.Map;

public class DiscourseUtils {

    static Logger logger = LoggerFactory.getLogger(DiscourseUtils.class);

    static Map<WordCloudBackground, File> map = new HashedMap();

    static {

        try {

            map.put(WordCloudBackground.CAT, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "cat.bmp"));
            map.put(WordCloudBackground.CLOUD, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "cloud_fg.bmp"));
            map.put(WordCloudBackground.CLOUD_BG, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "cloud_bg.bmp"));
            map.put(WordCloudBackground.DRAGON, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "dragon.png"));
            map.put(WordCloudBackground.EARTH, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "earth.bmp"));
            map.put(WordCloudBackground.WECHAT, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "wechat.png"));
            map.put(WordCloudBackground.WHALE, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "whale_small.png"));
            map.put(WordCloudBackground.LOGO, new File(CONSTANTS.BACKGROUND_IMAGE_PATH + "sm-logo.png"));
            map.put(WordCloudBackground.CUSTOM, null);

        } catch (Exception e2) {
            logger.error("读取词云背景图片失败");
            e2.getStackTrace();
        }
    }

    public static File getImageName(WordCloudBackground background) {
        return map.get(background);
    }


    /**
     * 取得tyepe
     *
     * @param type
     * @return
     */
    public static WordCloudBackground getWordCloudType(String type) {

        for (WordCloudBackground s : WordCloudBackground.values()) {
            if (type.toUpperCase().equals(s.toString().toUpperCase())) {
                return s;
            }
        }
        return null;

    }
}
